<!DOCTYPE html>

<html lang="en">
<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
  <meta name="baidu-site-verification" content="GOgEP8c1pN"/>
  

  <title>
    页面侧边栏：使用自定义模板标签_Django博客教程_追梦人物的博客</title>

  <link href="font-awesome.min.css"
        rel="stylesheet">
  <link rel="stylesheet" href="mobi.min.css">
  <link rel="stylesheet" href="modal.min.css">
  <link rel="stylesheet" href="friendly.css">
  <link rel="stylesheet" href="blog.css?v0.12">
  <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  <script src="/static/blog/js/menu.js"></script>
  <script src="/static/blog/js/modal.min.js"></script>
  <script src="/static/blog/js/blog.js"></script>
  

  
    <script>
        // baidu statistics
        var _hmt = _hmt || [];
        (function () {
            var hm = document.createElement("script");
            hm.src = "https://hm.baidu.com/hm.js?fb59b2a6022bccc02671a750f61c356b";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
        })();

        // baidu auto push
        (function () {
            var bp = document.createElement('script');
            var curProtocol = window.location.protocol.split(':')[0];
            if (curProtocol === 'https') {
                bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
            }
            else {
                bp.src = 'http://push.zhanzhang.baidu.com/push.js';
            }
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(bp, s);
        })();
    </script>
    
  
</head>
<body class="bg-light">
<header>
  <nav class="flex-center bg-white nav-bar">
    <div class="container-wider flex-middle">
      
  <a class="show-on-mobile nav-link m-5" id="js-sidebar-btn" href="#" role="button">
    <i class="fa fa-chevron-right" aria-hidden="true"></i>
  </a>

      <a class="nav-bar-logo mr-7" href="/">
        <img src="/static/blog/images/logo.png" alt="blog logo">
      </a>
      <ul class="unit-0 hide-on-mobile nav-bar-nav">
        <li class="nav-item mr-7">
          <a class="nav-link" href="/">首页</a>
        </li>
        <li class="nav-item mr-7">
          <a class="nav-link" href="/tutorials/">教程</a>
        </li>
        <li class="nav-item mr-7">
          <a class="nav-link" href="/categories/">分类</a>
        </li>
        <li class="nav-item mr-7">
          <a class="nav-link" href="/archives/">归档</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="/donate/">赞助</a>
        </li>
      </ul>
      <div class="unit flex-right flex-middle">
        <form class="hide-on-mobile flex-left flex-middle search-form mr-5" id="search-form"
              action="/search/">
          <input class="unit" type="search" name="q" placeholder="搜索..."/>
          <button class="unit-0" type="submit" role="button">
            <i class="fa fa-search" aria-hidden="true"></i>
          </button>
        </form>
        <a class="show-on-mobile nav-link fs-7 mr-7" id="js-search-btn" href="#" role="button">
          <i class="fa fa-search" aria-hidden="true"></i>
        </a>
        <div class="flex-middle notification">
          
            <a class="nav-link" href="/accounts/login/">
              <i class="fa fa-sign-in" aria-hidden="true"></i>
            </a>
          
        </div>
        <div class="show-on-mobile flex-middle">
          <a class="nav-link fs-7 ml-7 mr-5" id="menu-toggle" href="#">
            <i class="fa fa-ellipsis-v" aria-hidden="true"></i>
          </a>
          <ul class="menu bg-white" data-menu data-menu-toggle="#menu-toggle">
            <li class="nav-item mr-7">
              <a class="nav-link" href="/">首页</a>
            </li>
            <li>
              <a href="/tutorials/">教程</a>
            </li>
            <li>
              <a href="/categories/">分类</a>
            </li>
            <li>
              <a href="/archives/">归档</a>
            </li>
            <li>
              <a href="/donate/">赞助</a>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </nav>
</header>
<section class="flex-center">
  <div class="container-wider">
    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
         aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
              &times;
            </button>
            <h4 class="modal-title" id="myModalLabel">设置评论回复接收邮箱</h4>
            <div class="text-primary mt-2">邮箱仅用于接收回复提醒，不会被公开。</div>
            
          </div>
          <div class="modal-body">
            <form class="form email-binding-form" action="/comments/ajax_email_binding/">
              <div class="message">
                <span class="text-danger"></span>
              </div>
              <input type='hidden' name='csrfmiddlewaretoken' value='DqLmHHOPb6akhW32IHRkmxshZj6lHpVjgsKeFjb31YLo1rJxztewEQGyCpLddA5p' />
              <div class="flex-left units-gap">
                <label class="unit-0 text-right" for="multiple-inputs-name">邮箱: </label>
                <div class="unit">
                  <input type="email" name="email" id="id_email" placeholder="请输入绑定邮箱"/>
                </div>
                <div class="unit-0">
                  <button class="btn" id="js-send" type="button"
                          data-target="/comments/ajax_verification_code/">发送验证码
                  </button>
                </div>
              </div>
              <div class="flex-left units-gap">
                <label class="unit-0 text-right" for="multiple-inputs-name">验证码: </label>
                <div class="unit">
                  <input type="text" name="verification_code" id="id_verification_code"
                         placeholder="请输入接收到的验证码"/>
                </div>
              </div>
              <div class="flex-right">
                <button type="button" class="btn btn-danger mr-3" data-dismiss="modal">关闭</button>
                <button type="submit" class="btn btn-primary" id="js-submit">设置</button>
              </div>
            </form>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal -->
    </div>
    <div class="flex-left flex-wrap "
         style="margin-top: 60px">
      
  <aside class="unit-1-4 unit-1-on-mobile top-gap">
    <div class="scroll-view bg-white card toc-sidebar" style="height: 100%">
      <div class="card-header">
        目录
      </div>
      <div class="flex-left">
        <div class="unit-1-4">
          <a href="https://promotion.aliyun.com/ntms/act/group/team.html?group=FcfAncJPAp" target="_blank"><img
              src="/static/blog/images/aliyun.jpg" alt=""></a>
        </div>
        <div class="unit-1-2 flex-vertical top-gap text-small">
          <a style="color: #e83e8c" target="_blank"
             href="https://promotion.aliyun.com/ntms/act/group/team.html?group=FcfAncJPAp">云服务器新用户</a>
          <a style="color: #6610f2" target="_blank"
             href="https://promotion.aliyun.com/ntms/act/group/team.html?group=FcfAncJPAp">8元/月</a>
        </div>
      </div>
      <div class="card-body">
        <ul>
          <li>
            <h6 class="top-gap-0"><a href="">Django博客教程</a></h6>
            <ul>
              
                <li>
                  <a href="2.html">前言</a>
                  
                </li>
              
                <li>
                  <a href="3.html">搭建开发环境</a>
                  
                </li>
              
                <li>
                  <a href="4.html">建立 Django 博客应用</a>
                  
                </li>
              
                <li>
                  <a href="5.html">创建 Django 博客的数据库模型</a>
                  
                </li>
              
                <li>
                  <a href="6.html">让 Django 完成翻译：迁移数据库</a>
                  
                </li>
              
                <li>
                  <a href="7.html">Django 博客首页视图</a>
                  
                </li>
              
                <li>
                  <a href="8.html">真正的 Django 博客首页视图</a>
                  
                </li>
              
                <li>
                  <a href="9.html">在 Django Admin 后台发布文章</a>
                  
                </li>
              
                <li>
                  <a href="10.html">博客文章详情页</a>
                  
                </li>
              
                <li>
                  <a href="11.html">支持 Markdown 语法和代码高亮</a>
                  
                </li>
              
                <li>
                  <a href="12.html">页面侧边栏：使用自定义模板标签</a>
                  
                    <div class="toc">
<ul>
<li><a href="#使用模板标签的解决思路">使用模板标签的解决思路</a></li>
<li><a href="#模板标签目录结构">模板标签目录结构</a></li>
<li><a href="#编写模板标签代码">编写模板标签代码</a><ul>
<li><a href="#最新文章模板标签">最新文章模板标签</a></li>
<li><a href="#归档模板标签">归档模板标签</a></li>
<li><a href="#分类模板标签">分类模板标签</a></li>
</ul>
</li>
<li><a href="#使用自定义的模板标签">使用自定义的模板标签</a></li>
<li><a href="#总结">总结</a></li>
</ul>
</div>

                  
                </li>
              
                <li>
                  <a href="13.html">分类与归档</a>
                  
                </li>
              
                <li>
                  <a href="14.html">评论</a>
                  
                </li>
              
                <li>
                  <a href="16.html">已知小问题修正</a>
                  
                </li>
              
                <li>
                  <a href="20.html">使用 Nginx 和 Gunicorn 部署 Django 博客</a>
                  
                </li>
              
                <li>
                  <a href="21.html">使用 Fabric 自动化部署</a>
                  
                </li>
              
                <li>
                  <a href="29.html">统计文章阅读量</a>
                  
                </li>
              
                <li>
                  <a href="32.html">自动生成文章摘要</a>
                  
                </li>
              
                <li>
                  <a href="33.html">基于类的通用视图：ListView 和 DetailView</a>
                  
                </li>
              
                <li>
                  <a href="34.html">Django Pagination 简单分页</a>
                  
                </li>
              
                <li>
                  <a href="37.html">Django Pagination 完善分页</a>
                  
                </li>
              
                <li>
                  <a href="38.html">统计各个分类下的文章数</a>
                  
                </li>
              
                <li>
                  <a href="39.html">标签云</a>
                  
                </li>
              
                <li>
                  <a href="41.html">RSS 订阅</a>
                  
                </li>
              
                <li>
                  <a href="43.html">Markdown 自动生成文章目录</a>
                  
                </li>
              
                <li>
                  <a href="44.html">简单全文搜索</a>
                  
                </li>
              
                <li>
                  <a href="45.html">Django Haystack 全文检索与关键词高亮</a>
                  
                </li>
              
            </ul>
          </li>
        </ul>
      </div>
    </div>
  </aside>

      
  <div class="unit-3-4 unit-1-on-mobile top-gap">
    


<div class="bg-white card post-card px-7 py-5">
  
<article class="post">
  <h1 class="top-gap-0">页面侧边栏：使用自定义模板标签</h1>
  <ul class="list-inline dot-divider post-meta">
    <li class="list-inline-item text-small text-muted">
      12 月前
    </li>
    <li class="list-inline-item text-small text-muted">5808 字
    </li>
    <li class="list-inline-item text-small text-muted">
      21749 阅读
    </li>
    <li class="list-inline-item text-small text-muted">
      74 评论
    </li>
  </ul>
  <div class="top-gap-big post-body">
    <p>我们的博客侧边栏有四项内容：最新文章、归档、分类和标签云。这些内容相对比较固定，且在各个页面都会显示，如果像文章列表或者文章详情一样，从视图函数中获取然后传递给模板，则每个页面对应的视图函数里都要写一段获取这些内容的代码，这会导致很多重复代码。更好的解决方案是直接在模板中获取，为此，我们使用 Django 的一个新技术：自定义模板标签来完成任务。</p>
<h2 id="使用模板标签的解决思路">使用模板标签的解决思路</h2>
<p>我们前面已经接触过一些 Django 内置的模板标签，比如比较简单的 {% static %} 模板标签，这个标签帮助我们在模板中引入静态文件。还有比较复杂的如 {% for %} {% endfor%} 标签。这里 我们希望自己定义一个模板标签，例如名为 <code>get_recent_posts</code> 的模板标签，它可以这样工作：我们只要在模板中写入 {% get_recent_posts as recent_post_list %}，那么模板中就会有一个从数据库获取的最新文章列表，并通过 as 语句保存到 <code>recent_post_list</code> 模板变量里。这样我们就可以通过 {% for %} {% endfor%} 模板标签来循环这个变量，显示最新文章列表了，这和我们在编写博客首页面视图函数是类似的。首页视图函数中从数据库获取文章列表并保存到 <code>post_list</code> 变量，然后把这个 <code>post_list</code> 变量传给模板，模板使用 for 模板标签循环这个文章列表变量，从而展示一篇篇文章。这里唯一的不同是我们从数据库获取文章列表的操作不是在视图函数中进行，而是在模板中通过自定义的 {% get_recent_posts %} 模板标签进行。</p>
<p>以上就是解决思路，但模板标签不是我们随意写的，必须遵循 Django 的规范我们才能在 Django 的模板系统中使用自定义的模板标签，下面我们就依照这些规范来实现我们的需求。</p>
<h2 id="模板标签目录结构">模板标签目录结构</h2>
<p>首先在我们的 <strong>blog 应用</strong>下创建一个 templatetags 文件夹。然后在这个文件夹下创建一个 __init__.py 文件，使这个文件夹成为一个 Python 包，之后在 templatetags\ 目录下创建一个 blog_tags.py  文件，这个文件存放自定义的模板标签代码。</p>
<p>此时你的目录结构应该是这样的：</p>
<div class="codehilite"><pre><span></span>blog\
    __init__.py
    admin.py
    apps.py
    migrations\
        __init__.py
    models.py
    static\
    templatetags\
        __init__.py
        blog_tags.py
    tests.py
    views.py
</pre></div>


<h2 id="编写模板标签代码">编写模板标签代码</h2>
<p>接下来就是编写各个模板标签的代码了，自定义模板标签代码写在 blog_tags.py 文件中。其实模板标签本质上就是一个 Python 函数，因此按照 Python 函数的思路来编写模板标签的代码就可以了，并没有任何新奇的东西或者需要新学习的知识在里面。</p>
<h3 id="最新文章模板标签">最新文章模板标签</h3>
<p>打开 blog_tags.py 文件，开始写我们的最新文章模板标签。</p>
<div class="codehilite"><pre><span></span><span class="n">blog</span><span class="o">/</span><span class="n">templatetags</span><span class="o">/</span><span class="n">blog_tags</span><span class="o">.</span><span class="n">py</span>

<span class="kn">from</span> <span class="nn">..models</span> <span class="kn">import</span> <span class="n">Post</span>

<span class="k">def</span> <span class="nf">get_recent_posts</span><span class="p">(</span><span class="n">num</span><span class="o">=</span><span class="mi">5</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">Post</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="s1">&#39;-created_time&#39;</span><span class="p">)[:</span><span class="n">num</span><span class="p">]</span>
</pre></div>


<p>这个函数的功能是获取数据库中前 <code>num</code> 篇文章，这里 <code>num</code> 默认为 5。函数就这么简单，但目前它还只是一个纯 Python 函数，Django 在模板中还不知道该如何使用它。为了能够通过 {% get_recent_posts %} 的语法在模板中调用这个函数，必须按照 Django 的规定注册这个函数为模板标签，方法如下：</p>
<div class="codehilite"><pre><span></span><span class="n">blog</span><span class="o">/</span><span class="n">templatetags</span><span class="o">/</span><span class="n">blog_tags</span><span class="o">.</span><span class="n">py</span>

<span class="kn">from</span> <span class="nn">django</span> <span class="kn">import</span> <span class="n">template</span>
<span class="kn">from</span> <span class="nn">..models</span> <span class="kn">import</span> <span class="n">Post</span>

<span class="n">register</span> <span class="o">=</span> <span class="n">template</span><span class="o">.</span><span class="n">Library</span><span class="p">()</span>

<span class="nd">@register.simple_tag</span>
<span class="k">def</span> <span class="nf">get_recent_posts</span><span class="p">(</span><span class="n">num</span><span class="o">=</span><span class="mi">5</span><span class="p">):</span>
    <span class="k">return</span> <span class="n">Post</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span><span class="o">.</span><span class="n">order_by</span><span class="p">(</span><span class="s1">&#39;-created_time&#39;</span><span class="p">)[:</span><span class="n">num</span><span class="p">]</span>
</pre></div>


<p>这里我们首先导入 template 这个模块，然后实例化了一个 <code>template.Library</code> 类，并将函数 <code>get_recent_posts</code> 装饰为 <code>register.simple_tag</code>。这样就可以在模板中使用语法  {% get_recent_posts %} 调用这个函数了。</p>
<p><strong>注意 Django 1.9 后才支持 simple_tag 模板标签，如果你使用的 Django 版本小于 1.9，你将得到一个错误。Django 1.9 以前的版本如何自定义模板标签这里不再赘述。</strong> </p>
<h3 id="归档模板标签">归档模板标签</h3>
<p>和最新文章模板标签一样，先写好函数，然后将函数注册为模板标签即可。</p>
<div class="codehilite"><pre><span></span><span class="n">blog</span><span class="o">/</span><span class="n">templatetags</span><span class="o">/</span><span class="n">blog_tags</span><span class="o">.</span><span class="n">py</span>

<span class="nd">@register.simple_tag</span>
<span class="k">def</span> <span class="nf">archives</span><span class="p">():</span>
    <span class="k">return</span> <span class="n">Post</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">dates</span><span class="p">(</span><span class="s1">&#39;created_time&#39;</span><span class="p">,</span> <span class="s1">&#39;month&#39;</span><span class="p">,</span> <span class="n">order</span><span class="o">=</span><span class="s1">&#39;DESC&#39;</span><span class="p">)</span>
</pre></div>


<p>这里 <code>dates</code> 方法会返回一个列表，列表中的元素为每一篇文章（Post）的创建时间，且是 Python 的 <code>date</code> 对象，精确到月份，降序排列。接受的三个参数值表明了这些含义，一个是 <code>created_time</code> ，即 <code>Post</code> 的创建时间，<code>month</code> 是精度，<code>order='DESC'</code> 表明降序排列（即离当前越近的时间越排在前面）。例如我们写了 3 篇文章，分别发布于 2017 年 2 月 21 日、2017 年 3 月 25 日、2017 年 3 月 28 日，那么 <code>dates</code> 函数将返回 2017 年 3 月 和 2017 年 2 月这样一个时间列表，且降序排列，从而帮助我们实现按月归档的目的。</p>
<h3 id="分类模板标签">分类模板标签</h3>
<p>过程还是一样，先写好函数，然后将函数注册为模板标签。注意分类模板标签函数中使用到了 <code>Category</code> 类，其定义在 blog.models.py 文件中，使用前记得先导入它，否则会报错。 </p>
<div class="codehilite"><pre><span></span><span class="n">blog</span><span class="o">/</span><span class="n">templatetags</span><span class="o">/</span><span class="n">blog_tags</span><span class="o">.</span><span class="n">py</span>

<span class="kn">from</span> <span class="nn">..models</span> <span class="kn">import</span> <span class="n">Post</span><span class="p">,</span> <span class="n">Category</span>

<span class="nd">@register.simple_tag</span>
<span class="k">def</span> <span class="nf">get_categories</span><span class="p">():</span>
    <span class="c1"># 别忘了在顶部引入 Category 类</span>
    <span class="k">return</span> <span class="n">Category</span><span class="o">.</span><span class="n">objects</span><span class="o">.</span><span class="n">all</span><span class="p">()</span>
</pre></div>


<p>尽管侧边栏有 4 项内容（还有一个标签云），但是这里我们只实现最新文章、归档和分类数据的显示，还有一个标签云没有实现。因为标签云的实现稍有一点不同，所以将在接下来的教程中专门介绍。这里你也可以尝试着自己解决，如果遇到问题，可以通过官方文档或者搜索引擎求助。独立思考并寻求解决方案以及善用搜索引擎是一个开发者必须培养的能力，只有这样你才能成为一个独立的开发者，独立地解决别人可能从来没有遇到过的问题。</p>
<h2 id="使用自定义的模板标签">使用自定义的模板标签</h2>
<p>打开 base.html，为了使用模板标签，我们首先需要在模板中导入存放这些模板标签的模块，这里是 blog_tags.py 模块。当时我们为了使用 static 模板标签时曾经导入过 {% load staticfiles %}，这次在 {% load staticfiles %} 下再导入 blog_tags：</p>
<div class="codehilite"><pre><span></span>templates/base.html

{% load staticfiles %}
{% load blog_tags %}
<span class="cp">&lt;!DOCTYPE html&gt;</span>
<span class="p">&lt;</span><span class="nt">html</span><span class="p">&gt;</span>
...
<span class="p">&lt;/</span><span class="nt">html</span><span class="p">&gt;</span>
</pre></div>


<p>然后找到最新文章列表处，把里面的列表修改一下：</p>
<div class="codehilite"><pre><span></span>templates/base.html

<span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;widget widget-recent-posts&quot;</span><span class="p">&gt;</span>
  <span class="p">&lt;</span><span class="nt">h3</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;widget-title&quot;</span><span class="p">&gt;</span>最新文章<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
  {% get_recent_posts as recent_post_list %}
  <span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
    {% for post in recent_post_list %}
    <span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span>
      <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;{{ post.get_absolute_url }}&quot;</span><span class="p">&gt;</span>{{ post.title }}<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
    <span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
    {% empty %}
    暂无文章！
    {% endfor %}
  <span class="p">&lt;/</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
</pre></div>


<p>这里我们通过使用 <code>get_recent_posts</code> 模板标签获取到最新文章列表，然后我们通过 as 语法（Django 模板系统的语法）将获取的文章列表保存进了 <code>recent_post_list</code> 模板变量中，之后就可以通过 for 循环来循环显示文章列表数据了，这和我们在写首页视图时是一样的。</p>
<p>然后是归档部分：</p>
<div class="codehilite"><pre><span></span>templates/base.html

<span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;widget widget-archives&quot;</span><span class="p">&gt;</span>
  <span class="p">&lt;</span><span class="nt">h3</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;widget-title&quot;</span><span class="p">&gt;</span>归档<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
  {% archives as date_list %}
  <span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
    {% for date in date_list %}
    <span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span>
      <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;#&quot;</span><span class="p">&gt;</span>{{ date.year }} 年 {{ date.month }} 月<span class="p">&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
    <span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
    {% empty %}
    暂无归档！
    {% endfor %}
  <span class="p">&lt;/</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
</pre></div>


<p>同样，这里我们调用 <code>archives</code> 模板标签自动获取一个已发表文章的日期列表，精确到月份，降序排列，然后通过 as 语法将其保存在 <code>date_list</code> 模板变量里。由于日期列表中的元素为 Python 的 <code>date</code> 对象，因此可以通过其 <code>year</code> 和 <code>month</code> 属性分别获取年和月的信息，<code>&lt;a href="#"&gt;{{ date.year }} 年 {{ date.month }} 月&lt;/a&gt;</code> 反应了这个事实。</p>
<p>分类部分也一样：</p>
<div class="codehilite"><pre><span></span><span class="p">&lt;</span><span class="nt">div</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;widget widget-category&quot;</span><span class="p">&gt;</span>
  <span class="p">&lt;</span><span class="nt">h3</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;widget-title&quot;</span><span class="p">&gt;</span>分类<span class="p">&lt;/</span><span class="nt">h3</span><span class="p">&gt;</span>
  {% get_categories as category_list %}
  <span class="p">&lt;</span><span class="nt">ul</span><span class="p">&gt;</span>
    {% for category in category_list %}
    <span class="p">&lt;</span><span class="nt">li</span><span class="p">&gt;</span>
      <span class="p">&lt;</span><span class="nt">a</span> <span class="na">href</span><span class="o">=</span><span class="s">&quot;#&quot;</span><span class="p">&gt;</span>{{ category.name }} <span class="p">&lt;</span><span class="nt">span</span> <span class="na">class</span><span class="o">=</span><span class="s">&quot;post-count&quot;</span><span class="p">&gt;</span>(13)<span class="p">&lt;/</span><span class="nt">span</span><span class="p">&gt;&lt;/</span><span class="nt">a</span><span class="p">&gt;</span>
    <span class="p">&lt;/</span><span class="nt">li</span><span class="p">&gt;</span>
    {% empty %}
    暂无分类！
    {% endfor %}
  <span class="p">&lt;/</span><span class="nt">ul</span><span class="p">&gt;</span>
<span class="p">&lt;/</span><span class="nt">div</span><span class="p">&gt;</span>
</pre></div>


<p><code>&lt;span class="post-count"&gt;(13)&lt;/span&gt;</code> 显示的是该分类下的文章数目，这个特性会在接下来的教程中讲解如何实现，目前暂时用占位数据代替吧。</p>
<p>现在运行开发服务器，可以看到侧边栏显示的数据已经不再是之前的占位数据，而是我们保存在数据库中的数据了。</p>
<p><strong>注意</strong>：如果你按照教程的步骤做完后发现报错，请按以下顺序检查。</p>
<ol>
<li>检查目录结构是否正确。确保 templatetags\ 位于 blog\ 目录下，且目录名必须为 templatetags。具体请对照上文给出的目录结构。</li>
<li>确保  templatetags\ 目录下有 __init__.py 文件。</li>
<li>确保使用的 Django 版本不小于 1.9。</li>
<li>确保通过 <code>register = template.Library()</code> 和  <code>@register.simple_tag</code> 装饰器将函数装饰为一个模板标签。</li>
<li>确保在使用模板标签以前导入了 blog_tags，即 {% load blog_tags %}。<strong>注意要在使用任何 blog_tags 下的模板标签以前导入它。</strong>  </li>
<li>确保模板标签的语法使用正确，即 {% load blog_tags %}，注意 { 和 % 以及 % 和 } 之间没有任何空格。</li>
</ol>
<h2 id="总结">总结</h2>
<p>本章节的代码位于：<a href="https://github.com/zmrenwu/django-blog-tutorial/tree/Step10_side-bar">Step10: side bar</a>。</p>
<p>如果遇到问题，请通过下面的方式寻求帮助。</p>
<ul>
<li>在下方评论区留言。</li>
<li>将问题的详细描述通过邮件发送到 djangostudyteam@163.com，一般会在 24 小时内回复。</li>
<li>在 <a href="http://www.pythonzh.cn/category/newbie-qa/">Pythonzhcn 社区的新手问答版块</a> 发布帖子。</li>
</ul>
    <p class="text-center">
      -- EOF --
    </p>
    <div>
      <button class="btn btn-primary" id="js-reward"><i class="fa fa-jpy"
                                                        aria-hidden="true"></i>
        如果觉得文章对你有帮助，请随意打赏
        <i class="fa fa-chevron-down" aria-hidden="true"></i>
      </button>
      <div class="flex-left flex-wrap units-gap-big mt-4" style="display: none">
        <div class="unit unit-1-on-mobile flex-center">
          <figure>
            <img src="/static/blog/images/weixinpay.jpg" alt="微信支付收款二维码"
                 style="width: 250px">
            <figcaption class="text-center fs-6 mt-2" style="color: green">微信</figcaption>
          </figure>
        </div>
        <div class="unit unit-1-on-mobile flex-center">
          <figure>
            <img src="/static/blog/images/alipay.jpg" alt="支付宝收款二维码" style="width: 250px">
            <figcaption class="text-center fs-6 mt-2 text-primary">支付宝</figcaption>
          </figure>
        </div>
      </div>
    </div>
    <div class="post-tags">
      <ul class="list-inline">
        
      </ul>
    </div>
  </div>
</article>
  <div class="top-gap">
    <div class="jiathis_style">
      <span class="jiathis_txt">分享到：</span>
      <a class="jiathis_button_qzone">QQ空间</a>
      <a class="jiathis_button_tsina">新浪微博</a>
      <a class="jiathis_button_tqq">腾讯微博</a>
      <a class="jiathis_button_weixin">微信</a>
      <a href="http://www.jiathis.com/share?uid=2128865"
         class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis"
         target="_blank">更多</a>
      <a class="jiathis_counter_style"></a>
    </div>
    <script type="text/javascript">
        var jiathis_config = {data_track_clickback: 'true'};
    </script>
    <script type="text/javascript" src="http://v3.jiathis.com/code/jia.js?uid=2128865"
            charset="utf-8"></script>
    <!-- JiaThis Button END -->
  </div>
  <br>
  <div class="top-gap clearfix">
    
      <a href="11.html">
        <i class="fa fa-angle-double-left" aria-hidden="true"></i>
        支持 Markdown 语法和代码高亮
      </a>
    
    
      <a class="float-right" href="13.html">
        分类与归档
        <i class="fa fa-angle-double-right" aria-hidden="true"></i>
      </a>
    
  </div>
  

  <section class="comment-area top-gap-big" id="comment-area">
    <h5>74 条评论 / 42 人参与</h5>
    
      
<div class="flex-center top-gap login-panel p-7">
  <div>
    <div class="text-muted text-center login-header"><span>登录后回复</span></div>
    <div class="flex-center text-center social-icons mt-3">
                        <span class="weibo mr-3">
                            <a href="/accounts/weibo/login/">
                                <i class="fa fa-weibo" aria-hidden="true"></i>
                            </a>
                        </span>
      <span class="github">
                            <a href="/accounts/github/login/">
                                <i class="fa fa-github" aria-hidden="true"></i>
                            </a>
                        </span>
    </div>
  </div>
</div>
    
    <div class="top-gap-big comment-list">
  
    <div class="flex-left py-4" id="c2368">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/36990176?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">amou1758
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>确保使用的 Django 版本不小于 1.9。<br></p><p><br></p><p><br></p><p>我用的1.11.8的版本&nbsp; 按照步骤没有出错</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 周，3 日前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2368"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2317">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/31679693?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">wang
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>我看到有些同学出现了</p><ul><li>django.template.exceptions.TemplateSyntaxError: 'blog_tags' is not a registered tag library. Must be one of:</li><li>&nbsp;admin_list&nbsp;</li><li>admin_modify&nbsp;</li><li>admin_static&nbsp;</li><li>admin_urls&nbsp;</li><li>cache</li><li>&nbsp;i18n&nbsp;</li><li>l10n&nbsp;</li><li>log&nbsp;</li><li>static&nbsp;</li><li>staticfiles</li><li>&nbsp;tz<br></li></ul><p>的错误，我出现这个错误的原因是我的应用名是myblog，并没有用老师的blog，然后我改名了之后用{% load myblog_tags %}就可以了</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">1 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2317"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2289">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/24679964?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">zhazhalaila
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>Django 2.0版本不需要</p><pre><code>{% load blog_tags %}</code></pre><p>写上反而会出错</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">1 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2289"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c2382">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars0.githubusercontent.com/u/33307906?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">lyg4795
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">zhazhalaila
        

  </header>
  <div class="comment-body">
    <p>2.0.3写上没错</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2382"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2224">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva1.sinaimg.cn/crop.0.26.1242.1242.180/abe70a7ajw8f46sl601ofj20yi0zygpf.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">keyones阳光积极正能量
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>操作报错</p><p>ValueError at /Cannot truncate TimeField 'created_time' to DateField. Request Method:GETRequest URL:<a href="http://localhost:8000/Django" rel="nofollow">http://localhost:8000/Django</a> Version:2.0.1Exception Type:ValueErrorException Value:Cannot truncate TimeField 'created_time' to DateField. Exception Location:C:\Users\Keyones\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\models\functions\datetime.py in resolve_expression, line 193Python Executable:C:\Users\Keyones\AppData\Local\Programs\Python\Python36\python.exePython Version:3.6.3Python Path:['E:\\kesites', 'E:\\kesites',&nbsp;<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2224"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c2194">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars0.githubusercontent.com/u/30865898?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">wanconglei
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>TemplateSyntaxError at /Invalid block tag on line 86: 'empty'. Did you forget to register or load this tag?<br></p><p>请问为什么会出现empty Tag报错，没有用自定义 Tag之前没有报错啊。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2194"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1830">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.55.0.330.330.180/7dc66d33jw8ehx4dduhp3g20c8096759.gif"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Domon_Lee
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>各位使用Templatetags没有生效的朋友，可以参考下这个<a href="https://stackoverflow.com/questions/40686201/django-1-10-1-my-templatetag-is-not-a-registered-tag-library-must-be-one-of" rel="nofollow">https://stackoverflow.com/questions/40686201/django-1-10-1-my-templatetag-is-not-a-registered-tag-library-must-be-one-of</a><br>需要重启Django的服务器。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">4 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1830"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c2313">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.355.1183.1183.180/ca1089bejw8f1xvb6oaf4j20xc1n6tgz.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Pnorest
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Domon_Lee
        

  </header>
  <div class="comment-body">
    <p>stackoverflow的这个链接第二个有效，在settings的.py的templates中做自定义标签的引入</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">1 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2313"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c2353">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva4.sinaimg.cn/crop.0.0.996.996.180/005Y7ZHhjw8f2m7qocrsrj30ro0rpwfy.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">y正在输入
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Pnorest
        

  </header>
  <div class="comment-body">
    <p>您好 可以写一下自定义标签引入在本教程里的代码吗 我看了那个但是一直都试不对= =新手入门，请您多多指教！<br><br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">3 周，2 日前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2353"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1681">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/5253917?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">陈振兴
          
        </span>
    
  </header>
  <div class="comment-body">
    <p style="">对于@register.simple_tag这里</p><p style="">我在django 1.8.2环境中要用@resister.assignment_tag 赋值标签,才能 as 给其他变量.否则会报参数过多错误,有跟我一样问题的吗<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1681"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1692">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">陈振兴
        

  </header>
  <div class="comment-body">
    <p>版本兼容性问题，你的方法是对的。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1692"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1561">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/20895206?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Cecilia
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>为什么侧边栏显示暂无文章啊</p><pre><code class="lang-html">&lt;div class="widget widget-recent-posts"&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h3 class="widget-title"&gt;最新文章&lt;/h3&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% get_recent_posts as recent_post_list %}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ul&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% for post in rencent_post_list %}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;a href="{{post.get_absolute_url}}"&gt;{{post.title}}&lt;/a&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/li&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% empty %}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 暂无文章<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% endfor %}<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/ul&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br></code></pre><pre><code class="lang-html"># simple_tag是一个模板标签<br />@register.simple_tag<br />def get_recent_posts(num=5):<br />	return Post.objects.all().order_by('-create_time')[:num]<br /><br></code></pre>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1561"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1571">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.1.750.750.180/789a5119jw8f1eykyypblj20ku0kwtbm.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">小文心剑飞
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Cecilia
        

  </header>
  <div class="comment-body">
    <p>&lt;div class="widget widget-recent-posts"&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;h3 class="widget-title"&gt;最新文章&lt;/h3&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% get_recent_posts as recent_post_list %}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ul&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% for post in recent_post_list %}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;li&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;a href="{{ post.get_absolute_url }}"&gt;{{ post.title }}&lt;/a&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/li&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% empty %}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 暂无文章！&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {% endfor %}&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/ul&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/div&gt;<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1571"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1572">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.1.750.750.180/789a5119jw8f1eykyypblj20ku0kwtbm.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">小文心剑飞
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Cecilia
        

  </header>
  <div class="comment-body">
    <p>我重新复制了一下博主的代码，可以了</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1572"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1573">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/20895206?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Cecilia
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">小文心剑飞
        

  </header>
  <div class="comment-body">
    <p>我也是重新复制，不过我觉得这样好尴尬。</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1573"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1574">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.1.750.750.180/789a5119jw8f1eykyypblj20ku0kwtbm.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">小文心剑飞
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Cecilia
        

  </header>
  <div class="comment-body">
    <p>恩，不知道为什么，一样的代码</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1574"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1704">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars0.githubusercontent.com/u/17023204?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">侯梓煜
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Cecilia
        

  </header>
  <div class="comment-body">
    <p>你们代码不好用的时候是手打的么还是说复制上面去的？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1704"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1727">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/32827300?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">fshgrym
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Cecilia
        

  </header>
  <div class="comment-body">
    <p>没有查到数值吧<br><br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1727"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1542">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.1.750.750.180/789a5119jw8f1eykyypblj20ku0kwtbm.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">小文心剑飞
          
        </span>
    
  </header>
  <div class="comment-body">
    <p>博主，你好！为什么我的侧边栏都显示“暂无文章！”“暂无归档！”“暂无分类！”？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1542"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1562">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/20895206?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Cecilia
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">小文心剑飞
        

  </header>
  <div class="comment-body">
    <p>想问一下啊，你解决了嘛，我也遇到了这个问题</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1562"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1570">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.1.750.750.180/789a5119jw8f1eykyypblj20ku0kwtbm.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">小文心剑飞
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Cecilia
        

  </header>
  <div class="comment-body">
    <p>没有</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1570"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c1105">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/22127035?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">xueshichaoya
          
        </span>
    
  </header>
  <div class="comment-body">
    博主请教个问题，这个模板标签，归档部分有没有好的办法同时获得记录数？例如：2017-08（10条） 这样
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1105"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c1107">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">xueshichaoya
        

  </header>
  <div class="comment-body">
    参考文档 annotate 以及 aggregate 部分，不过我没有细致研究过。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1107"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c962">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.1.750.750.180/b6915e06jw8erwrq8wv7fj20ku0kwgmc.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">米粥fly怕素色pool
          
        </span>
    
  </header>
  <div class="comment-body">
    博主大大 按照你的步骤操作了一遍，页面上没出现侧边栏，也没报错。。。。什么情况啊？
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/962"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c963">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.1.750.750.180/b6915e06jw8erwrq8wv7fj20ku0kwgmc.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">米粥fly怕素色pool
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">米粥fly怕素色pool
        

  </header>
  <div class="comment-body">
    我知道了。。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/963"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c880">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/22904295?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">切了特空
          
        </span>
    
  </header>
  <div class="comment-body">
    重启服务没用，重启电脑就可以了。。。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/880"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
        <div class="comment-descendant-list">
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c852">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva1.sinaimg.cn/crop.0.0.800.800.180/005AQ7ZYjw8ert9y0qdzaj30m80m8dln.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">木犀草号
          
        </span>
    
  </header>
  <div class="comment-body">
    博主前辈：<br />InvalidTemplateLibrary at /<br />Invalid template library specified. ImportError raised when trying to load 'blog.templatetags.blog_tags': cannot import name 'templete'<br /><br />为什么  cannot import name 'templete'  ？？
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/852"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c853">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva1.sinaimg.cn/crop.0.0.800.800.180/005AQ7ZYjw8ert9y0qdzaj30m80m8dln.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">木犀草号
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">木犀草号
        

  </header>
  <div class="comment-body">
    啊········我把template 写成了 templete！！！！
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/853"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c805">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva4.sinaimg.cn/crop.0.0.664.664.180/b34e35bfjw8eyslbqaasqj20ig0ig756.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">静静地林子中有雨
          
        </span>
    
  </header>
  <div class="comment-body">
    博主，<br />from ..models import Post, Category<br />报错如下：<br />from ..models import Post, Category<br />SystemError: Parent module '' not loaded, cannot perform relative import<br />请问怎么解决呢？目录结构是对的
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/805"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c838">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva4.sinaimg.cn/crop.1.0.510.510.180/b1800604jw8fayxiwql92j20e80e6jry.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">真真正正正正
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">静静地林子中有雨
        

  </header>
  <div class="comment-body">
    请问下你这个问题解决了么，我也遇到了同样问题
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/838"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c859">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva4.sinaimg.cn/crop.160.0.1279.1279.180/8c7f5bccjw8e6rxmr0uk0j218g0zjado.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">KOI科少
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">静静地林子中有雨
        

  </header>
  <div class="comment-body">
    如果你是右边栏里的分类没有信息的话<br />那么你应该检查下你get_recent_posts里的方法里是否return了<br />def get_recent_post():<br />    return Post.objects.all().order_by('-created_time')<br />单独去运行python blog_tags.py是会报这个错误的 我也没有解决<br />但是对于项目来说没有影响貌似 只要跟着上面教程做然后记得有返回值就可以返回数据库中的数据列表了
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/859"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c910">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">静静地林子中有雨
        

  </header>
  <div class="comment-body">
    py3么？templatetags 的目录结构是不是和项目中的一样？
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/910"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c779">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars0.githubusercontent.com/u/25743779?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">LincolnBurrows2017
          
        </span>
    
  </header>
  <div class="comment-body">
    博主  我也是重启之后没有反应
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/779"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c780">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars0.githubusercontent.com/u/25743779?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">LincolnBurrows2017
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">LincolnBurrows2017
        

  </header>
  <div class="comment-body">
    django.template.exceptions.TemplateSyntaxError: 'blog_tags' is not a registered tag library. Must be one of:<br />admin_list<br />admin_modify<br />admin_static<br />admin_urls<br />cache<br />i18n<br />l10n<br />log<br />static<br />staticfiles<br />tz
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/780"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c942">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tvax2.sinaimg.cn/crop.0.0.400.400.180/a900d707ly8fi4on5u68cj20b40b4dga.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">没错我就是菊花侠
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">LincolnBurrows2017
        

  </header>
  <div class="comment-body">
    需要在settings里面加上STATIC_URL = '/templatetags/'
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/942"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1559">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/20895206?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Cecilia
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">没错我就是菊花侠
        

  </header>
  <div class="comment-body">
    <p>可是我打开setting的时候发现已经有</p><p>STATIC_URL = '/static/'</p><p>继续加上去的话，不会覆盖嘛</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">6 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1559"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1659">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tvax2.sinaimg.cn/crop.0.0.996.996.180/006mOlR7ly8fe01ouxlu3j30ro0rogqn.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Stallionshell
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Cecilia
        

  </header>
  <div class="comment-body">
    <p>见评论末尾，重启服务即可解决，无需修改settings</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1659"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c729">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/29838539?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">JBKylin
          
        </span>
    
  </header>
  <div class="comment-body">
    TemplateSyntaxError at /<br /><br />'./blog_tags' is not a valid tag library: Template library ./blog_tags not found, tried django.templatetags../blog_tags,django.contrib.admin.templatetags../blog_tags,django.contrib.staticfiles.templatetags../blog_tags<br />请问这是怎么回事，反复试了好几次都有问题
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/729"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c738">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">JBKylin
        

  </header>
  <div class="comment-body">
    重启一下服务器看看
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/738"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c716">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.0.480.480.180/ad53e755jw8ek5yu7uuiyj20dc0dcwf7.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">lucahai
          
        </span>
    
  </header>
  <div class="comment-body">
    好像markdown不能支持[]()蓝字链接语法？
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/716"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c746">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">lucahai
        

  </header>
  <div class="comment-body">
    支持呀，是不是格式不正确？
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/746"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c760">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.0.480.480.180/ad53e755jw8ek5yu7uuiyj20dc0dcwf7.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">lucahai
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    复制我自己在简书的文章过来，只有[]()不行...
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/760"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c784">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.0.480.480.180/ad53e755jw8ek5yu7uuiyj20dc0dcwf7.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">lucahai
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    您好，实际上应该是结果可以插入点开链接，但是字是黑色的不会变成蓝色，我误以为没有用，和其他文本颜色一样的话确实也很难知道可以点击
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/784"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c797">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">lucahai
        

  </header>
  <div class="comment-body">
    额，这个主题貌似就是这样，可以自己改改css链接颜色。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/797"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c847">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.0.0.480.480.180/ad53e755jw8ek5yu7uuiyj20dc0dcwf7.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">lucahai
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    谢谢~
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/847"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c869">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/26867628?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">chenzhixiang1992
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">lucahai
        

  </header>
  <div class="comment-body">
    谢谢
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/869"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c616">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/29838087?v=4"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">erwwwwwwww
          
        </span>
    
  </header>
  <div class="comment-body">
    我遇到了个问题：<br />'created_time' is a DateTimeField, not a DateField.<br />暂时的处理方法是:<br />在Django项目的settings.py文件中，可以直接设置为“USE_TZ = False”
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/616"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c628">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">erwwwwwwww
        

  </header>
  <div class="comment-body">
    你需要传入完整的 datetime 对象。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/628"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c803">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/7870718?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">Chen yongle
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">erwwwwwwww
        

  </header>
  <div class="comment-body">
    return Post.objects.dates('created_time', 'month', order='DESC')<br />这里dates改成datetimes，接着报错缺少pytz。安装pytz之后页面正常
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/803"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c918">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva2.sinaimg.cn/crop.0.0.512.512.180/0065vdXojw8f7hulv3szyj30e80e8jry.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">木二Lin
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">Chen yongle
        

  </header>
  <div class="comment-body">
    我的提示安装后我安装了还是报错，重启服务器也不行啊
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/918"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c2223">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva1.sinaimg.cn/crop.0.26.1242.1242.180/abe70a7ajw8f46sl601ofj20yi0zygpf.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">keyones阳光积极正能量
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">erwwwwwwww
        

  </header>
  <div class="comment-body">
    <p>请问这个最后怎么解决？</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2223"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c566">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="http://tvax4.sinaimg.cn/crop.0.3.506.506.180/af87807fly8fh1cgkubolj20e20e875c.jpg"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">逐殇小彬
          
        </span>
    
  </header>
  <div class="comment-body">
    TemplateSyntaxError at /<br />Invalid block tag on line 80: 'get_recent_posts'. Did you forget to register or load this tag?<br />-----------这边的base.xml部分内容为：  是有什么没有定义？<br /><div class="widget widget-recent-posts"><br />                    <h3 class="widget-title">最新文章</h3><br />                    {% get_recent_posts as recent_post_list %}<br />                    <ul><br />                        {% for post in recent_post_list %}<br />                        <li><br />                            <a href="{{ post.get_absolute_url }}">{{ post.title }}</a><br />                        </li><br />                        {% empty %}<br />                        暂无文章！<br />                        {% endfor %}<br />                    </ul><br />                </div>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/566"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c576">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">逐殇小彬
        

  </header>
  <div class="comment-body">
    你重启一下服务器试试。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，1 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/576"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1090">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars0.githubusercontent.com/u/8638272?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">rebortyang
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">逐殇小彬
        

  </header>
  <div class="comment-body">
    请问你的问题解决了吗？ 我也是相同的问题，找了一天都没有解决方法，希望你能给给回复，谢谢
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1090"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1110">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tvax4.sinaimg.cn/crop.0.3.506.506.180/af87807fly8fh1cgkubolj20e20e875c.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">逐殇小彬
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">rebortyang
        

  </header>
  <div class="comment-body">
    先试一下重启 这个问题我忘记记录了 忘记当时是怎么处理完成的   有可能是模板有问题  你那边可以试一下替换博主的本教程的模板内容看一下
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1110"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c442">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/15848000?v=3"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">shitianyi
          
        </span>
    
  </header>
  <div class="comment-body">
    请问一下，这段代码如果放在django1.8版本上该怎样修改？另外，我看django-1.8的手册上有simple_tag，为什么说django1.9以上才支持呢？
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/442"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c444">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">shitianyi
        

  </header>
  <div class="comment-body">
    1.9 之后才支持 as 语法，1.9以前你可以把 simple tag 改为 assignment tag
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/444"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c453">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/15848000?v=3"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">shitianyi
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    原来如此，谢谢博主。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">9 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/453"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
      <hr class="m-0">
    
  
    <div class="flex-left py-4" id="c90">
      <div class="unit-0">
        <img class="comment-avatar mr-3" src="https://avatars1.githubusercontent.com/u/15381809?v=3"/>
      </div>
      <div class="unit">
        <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">gleesu
          
        </span>
    
  </header>
  <div class="comment-body">
    add：需要重启服务器，才会生效。否则，报错：'blog_tags' is not a registered tag library. Must be one of: admin_list admin_modify admin_static admin_urls cache i18n l10n log static staticfiles tz
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月，4 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/90"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>
        
          <hr class="">
        
        <div class="comment-descendant-list">
          
            <div class="flex-left py-4" id="c182">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tvax2.sinaimg.cn/crop.384.0.1280.1280.180/6df9411aly1fhb8yuyd24j21kw0zkk0j.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">楔子_菜菜
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">gleesu
        

  </header>
  <div class="comment-body">
    对，需要重启。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月，2 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/182"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c354">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/25364828?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">King-Ye
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">gleesu
        

  </header>
  <div class="comment-body">
    重启服务器后还是报错,请问可能会是什么情况?<br />'blog_tags' is not a registered tag library. Must be one of: admin_list admin_modify admin_static admin_urls blog_tag cache i18n l10n log static staticfiles tz
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/354"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c355">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">King-Ye
        

  </header>
  <div class="comment-body">
    看看你的项目结构。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/355"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c356">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">King-Ye
        

  </header>
  <div class="comment-body">
    博客不方便粘贴代码的话请发在 http://pythonzh.cn/category/django/
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/356"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c367">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars3.githubusercontent.com/u/25364828?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">King-Ye
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    最近在期末考试,考完了之后我能直接在QQ上问您吗?
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/367"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c368">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">King-Ye
        

  </header>
  <div class="comment-body">
    嗯，可以的
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">10 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/368"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c709">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.284.124.711.711.180/e36b3443jw8fby25s070pj20zk0qowfn.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">饭团丶3
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    我也是同样的问题，重启不惯用，版本1.11<br />'blog_tags' is not a registered tag library. Must be one of:<br />admin_list<br />admin_modify<br />admin_static<br />admin_urls<br />cache<br />i18n<br />l10n<br />log<br />static<br />staticfiles<br />tz
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/709"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c750">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">饭团丶3
        

  </header>
  <div class="comment-body">
    按照教程中的检查提示做了还是没用么？
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/750"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c943">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tvax2.sinaimg.cn/crop.0.0.400.400.180/a900d707ly8fi4on5u68cj20b40b4dga.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">没错我就是菊花侠
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">饭团丶3
        

  </header>
  <div class="comment-body">
    在base.html中引用的{% load blog_tags %}需要指明blog_tags的路径，在setting.py里面加上STATIC_URL = '/templatetags/'即可
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/943"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c956">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/13174219?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">追梦人物
          
            <span class="master">[博主]</span>
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">没错我就是菊花侠
        

  </header>
  <div class="comment-body">
    blog_tags 是模板标签，这种做法是错误的。只要 blog_tags 所在的 app 已经加入了 INSTALLED_APPS 列表，django 应该就能导入这个模板标签的。
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">8 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/956"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1261">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars0.githubusercontent.com/u/20089093?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">edsszw
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">追梦人物
        
            <span class="master">[博主]</span>
        

  </header>
  <div class="comment-body">
    <p>这种情况主要重启一下本地服务器就好了。不需要更改&nbsp; STATIC_URL = '/static/'</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">7 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1261"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1757">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.53.213.533.533.180/005Hctu9jw8fbx217tvp0j30hs0qot90.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">大圣______
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">edsszw
        

  </header>
  <div class="comment-body">
    <p style="">重启和修改static都试过了，都不管用<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1757"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1765">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tva3.sinaimg.cn/crop.53.213.533.533.180/005Hctu9jw8fbx217tvp0j30hs0qot90.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">大圣______
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">大圣______
        

  </header>
  <div class="comment-body">
    <p style="">已解决，tempatetags放错目录了。<br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">5 月前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1765"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c1787">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="https://avatars2.githubusercontent.com/u/10209333?v=4"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">BastinT
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">edsszw
        

  </header>
  <div class="comment-body">
    <p>重启服务器也不一定有用，可能突然就好了。也不知道是什么原因<br><br></p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">4 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/1787"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
              <hr class="m-0">
            
          
            <div class="flex-left py-4" id="c2160">
              <div class="unit-0">
                <img class="comment-avatar mr-3" src="http://tvax1.sinaimg.cn/crop.0.71.258.258.180/b583a1bdly1fi6j1eagxyj20760b474v.jpg"/>
              </div>
              <div class="unit">
                
  <div class="comment-main">
  <header class="comment-user">
        <span class="text-small text-muted nickname">zzfeng2012
          
        </span>
    
    <span class="reply-label text-small text-muted">
                                                        <i class="fa fa-share" aria-hidden="true"></i>
                                                    </span>
    <span class="nickname text-small text-muted">BastinT
        

  </header>
  <div class="comment-body">
    <p>浏览器缓存...</p>
  </div>
  <footer class="comment-footer flex-left">
    <ul class="unit list-inline dot-divider">
      <li class="list-inline-item">
        <time class="text-small text-muted">2 月，3 周前</time>
      </li>
      <li class="list-inline-item">
        <a href="/comments/reply/2160"
           class="reply-btn text-small text-muted">回复</a>
      </li>
    </ul>
  </footer>
</div>

              </div>
            </div>
            
          
        </div>
      </div>
    </div>
    
  
</div>
  </section>
</div>
  </div>

    </div>
  </div>
</section>
<footer class="bg-white py-5 mt-5 text-small text-muted">
  <div class="flex-center">
    <div>&copy; 2017 追梦人物的博客</div>
  </div>
  
  
  
</footer>
<script>
    $('[data-menu]').menu();

    var InterValObj; //timer变量，控制时间
    var curCount = 120;//当前剩余秒数

    $('#js-send').on('click', function (event) {
        var $this = $(this);
        var $targetURL = $this.attr('data-target');
        $.post(
            $targetURL,
            {email: $('#id_email').val()},
            function (data) {
                if (data.ok) {
                    $this.attr("disabled", "true");
                    $this.text("重新发送验证码" + "(" + curCount + ")");
                    InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
                    $('.message')
                        .find('span')
                        .text(data.msg)
                } else {
                    $('.message').find('span').text(data.msg)
                }
            }
        );
        return false;
    });

    //timer处理函数
    function SetRemainTime() {
        if (curCount === 0) {
            window.clearInterval(InterValObj);//停止计时器
            $('#js-send').removeAttr("disabled");//启用按钮
            $('#js-send').text("重新发送验证码");
        }
        else {
            curCount--;
            $('#js-send').text("重新发送验证码" + "(" + curCount + ")");
        }
    }

    $('#js-submit').on('click', function (event) {
        var $this = $(this);
        var $form = $('.email-binding-form');
        var $targetURL = $form.attr('action');
        console.log($targetURL);

        $.post(
            $targetURL,
            {
                email: $('#id_email').val(),
                verification_code: $('#id_verification_code').val()
            },
            function (data) {
                if (data.ok) {
                    location.reload();
                } else {
                    $('.message')
                        .find('span')
                        .text(data.msg)
                }
            }
        );
        return false;
    });


    var editor = new Simditor({
        textarea: $('#id_comment'),
        placeholder: "提出你的见解...",
        toolbarFloat: false,
        cleanPaste: true,
        toolbar: [
            'bold',
            'italic',
            'underline',
            'strikethrough',
            'color',
            'ol',
            'ul',
            'blockquote',
            'code',
            'table',
            'link',
            'image',
            'hr'
        ]
    });
</script>


</body>
</html>